import {AppEnum} from "@/enum/appEnum";
import type { AppRouteRecordRaw, AppRouteModule } from '@/router/types';
// 处理modules文件
const modules = import.meta.globEager('./modules/**/*.ts');

const routeModuleList: AppRouteModule[] = [];

Object.keys(modules).forEach((key) => {
    const mod = modules[key].default || {};
    const modList = Array.isArray(mod) ? [...mod] : [mod];
    routeModuleList.push(...modList);
});

export const asyncRoutes = [...routeModuleList];
export const RootRoute: AppRouteRecordRaw = {
    path: '/',
    name: 'Root',
    redirect: AppEnum.BASE_HOME,
    meta: {
        title: 'Root',
    },
};
export const LoginRoute: AppRouteRecordRaw = {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/login.vue'),
    meta: {
        title: '登录',
    },
};
export const basicRoutes = [
    LoginRoute,
    RootRoute,
    ...asyncRoutes,
];
